import React from 'react';
import PropTypes from "prop-types";
function Child(props) {
    console.log("child->props",props);// {userName:"wangwu",age:18}
    return (
        <div>
            <h3>Child</h3>
            <p>userName:{props.userName}</p>
            <p>age:{props.age}</p>
            <p>sex:{props.sex}</p>
            <p>{props.arr}</p>
        </div>
    );
}
Child.propTypes = {
    // 类型必须是字符串
    userName:PropTypes.string,
    // 类型必须是数字且不允许是undefined
    age:PropTypes.number.isRequired,
    arr:PropTypes.array
}
Child.defaultProps = {
    sex:"女"
}

export default Child;